package bit.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bit.dao.BoardDAO;

public class BoardDeleteAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		String num = req.getParameter("num");
		String pwd = req.getParameter("pwd");
		String pwd1 = req.getParameter("pwd1");
		ActionForward forward = new ActionForward();
		if(pwd.equals(pwd1)){
			BoardDAO dao = new BoardDAO();
			int cnt = dao.boardDelete(num);
			if(cnt>0){
				forward.setPath("list.do");
				forward.setRedirect(true);
			}
		} else {
			forward.setPath("detail.do?num="+num);
			forward.setRedirect(true);
		}
		
		return forward;
	}

}
